﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLayer.Model.Services.Abstract;
using BusinessLayer.Model.Services.Concrete;
using BusinessLayer;
using DataAccess.Services.Abstract;
using DataAccess.Services;

namespace intecnologia.Admin
{
    public partial class UploadPictures : System.Web.UI.Page
    {
        ISessionService _sessionService = new SessionService();
        IGalleryService _galleryService = new GalleryService();
        IApplicationService _applicationService = new ApplicationService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (_sessionService.SessionExpired())
                Response.Redirect("~/Admin/Default.aspx");

            if (!IsPostBack)
                LoadPictureCategories();
        }

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string imgPath = _applicationService.ApplicationFolder + Constants.GalleryImagesFolder;

            lblError.Text = _galleryService.SavePicture(fuPictureUpload, 
                                                        tbDescription.Text, 
                                                        ddlPictureCategory.SelectedValue);
        }

        private void LoadPictureCategories()
        {
            ddlPictureCategory.DataSource = Constants.PictureCategories;
            ddlPictureCategory.DataBind();
        }
    }
}
